package com.kxq.zhuoyue.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kxq.zhuoyue.po.ClientGroup;
import com.kxq.zhuoyue.service.ClientGroupService;
import com.kxq.zhuoyue.util.result.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/clientGroup")
public class ClientGroupController {

    @Autowired
    private ClientGroupService service;

    @PostMapping("/weixin/{clientGroupId}")
    private AjaxResult select(@PathVariable String clientGroupId){
        List<ClientGroup> list = service.getChatGroupList(clientGroupId);
        return AjaxResult.success("",list);
    }
    @GetMapping("/weixin")
    public AjaxResult findAll(){
        List<ClientGroup> list= service.list();
        return AjaxResult.success(list);
    }
    @PostMapping("/findByNameLike")
    public AjaxResult findByNameLike(@RequestBody ClientGroup clientGroup){
        QueryWrapper<ClientGroup> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("group_mame",clientGroup.getClientGroupName());
        List<ClientGroup> list = service.list(queryWrapper);
        return AjaxResult.success(list);
    }
    @PostMapping("/insGroup")
    public AjaxResult insGroup(){
        List<ClientGroup> group = service.insGroup();
        return AjaxResult.success("获取会话内容存档内部群信息",group);
    }
    @PostMapping("/ChatGroupList")
    public  AjaxResult getChatGroupList(String clientGroupId){
        List<ClientGroup> list = service.getChatGroupList(clientGroupId);
        return AjaxResult.success(list);
    }
}
